<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xwk="http://http://code.google.com/p/xworks"
    xmlns:xwkS="http://code.google.com/p/xworks.site" 
    xmlns:xwkA="http://code.google.com/p/xworks.application" 
    xmlns:xwkP="http://code.google.com/p/xworks.page" 
    xmlns:inc="http://code.google.com/p/xworks..includes" 
	exclude-result-prefixes="xwk xwkS xwkA xwkP inc">

	<xsl:include href="xworks.includes.snippets.xsl"/>
	<xsl:include href="xworks.includes.objectfactory.xsl"/>
	<xsl:include href="xworks.includes.menus.xsl"/>
	<xsl:include href="xworks.includes.forms.xsl"/>

	<!-- key variables -->
	<xsl:key name="xwk:Tags" match="root/wap/tags/node" use="@name"/>
	<xsl:key name="xwk:AppTags" match="root/app/tags/node" use="@name"/>
	<xsl:key name="xwk:Requests" match="request" use="@name"/>
	<xsl:key name="xwk:Results" match="result" use="@name"/>
	<xsl:key name="xwk:F" match="formvars/node" use="@name"/>
	<xsl:key name="xwk:Column" match="@*" use="local-name()"/>
	<xsl:key name="xwk:QF" match="formvars/node | querystring/node" use="@name"/>
	<xsl:key name="xwk:Q" match="querystring/node" use="@name"/>
	<xsl:key name="xwk:C" match="cookievars/node" use="@name"/>
	<xsl:key name="xwk:Forms" match="forms/form" use="@name"/>

	<!-- internal variables -->
	<xsl:variable name="xwk_EXTENSION">.aspx</xsl:variable>
	
	<!-- useful global variables-->
	<xsl:variable name="xwk:DOC_ACTION" select="key('xwk:Tags', 'DOC_ACTION')"/>
	<xsl:variable name="xwk:PAGE_NAME" select="key('xwk:Tags', 'PAGE_NAME')"/>
	<xsl:variable name="xwk:ACTION_PATH" select="key('xwk:Tags', 'ACTION_PATH')"/>
	<xsl:variable name="xwk:MENU" select="document(key('xwk:AppTags','MENU_FILE'))"/>
	<xsl:variable name="xwk:ACTION" select="key('xwk:QF','xwk_action')"/>
	<xsl:variable name="xwk:BROWSER_VARS" select="root/wap/browser"/>
	<xsl:variable name="xwk:Errors" select="/root/app/error[node]"/><!-- throw node in there, make sure we have error nodes, and not empty <error/> -->

	<!-- 
		There are two top level possibilities <br/>
		1) html	- html doc (must be xhtml) set for xml document source <br/>
		2) root - XWK resulting xml document <br/>
	-->
	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="root">
				<xsl:call-template name="xwk:MAIN"/>	
			</xsl:when>
			<xsl:when test="html">
				<xsl:apply-templates select=". | @*" mode="xwk:identity_copy"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="node() | @*" mode="xwk:identity_copy">
		<xsl:copy>
			<xsl:apply-templates select="@*" mode="xwk:identity_copy"/>
			<xsl:apply-templates select="node()" mode="xwk:identity_copy"/>
		</xsl:copy>
	</xsl:template>

	<!-- convert snippets to html -->
	<xsl:template match="snippets" mode="xwk:identity_copy">
		<xsl:variable name="doc" select="concat('../../', @src)"/>
		<xsl:apply-templates select="document($doc)" mode="inc:snippets"/>
	</xsl:template>

	<!--
			Called from Top-Level when top level element is root, the result of using FWK and not overriding the default XML produced
		-->
		<xsl:template name="xwk:MAIN">
			<html>
				<xsl:call-template name="xwk:HEAD"/>
				<xsl:call-template name="xwkS:MAIN"/>
			</html>
		</xsl:template>


		<!--
		xwk:MAIN calls this template rule<br/>
		This template calls xwk:CSS and xwk:JSCRIPT
	-->
	<xsl:template name="xwk:HEAD">
		<head>
			<xsl:call-template name="xwk:CSS"/>
			<title><xsl:call-template name="xwk:TITLE"/></title>
			<xsl:call-template name="xwk:JSCRIPT"/>
		</head>
	</xsl:template>

	<xsl:template name="xwk:TITLE">
		Ade Framework
	</xsl:template>

	<!-- 
		Called From:  xwk:HEAD <br/>
		By Default: Imports the following CSS: <br/>
		/xwk.library.20.css/xwk_generic.css <br/>
		/xwk.library.20.css/xwk_style.css
		Calls: xwkS:CSS (your agency Site level CSS)
	-->
	<xsl:template name="xwk:CSS">
		<style type="text/css" media="all">
			@import "/xwk.codebase/library.css/xwk_results.css";
			@import "/xwk.codebase/library.css/xwk_generic.css";
			@import "/xwk.codebase/library.css/xwk_style.css";
			@import "/xwk.codebase/library.css/xwk_menus.css";
			@import "/xwk.codebase/library.css/xwk_forms.css";
			<xsl:call-template name="xwkS:CSS"/>
			<xsl:call-template name="xwkA:CSS"/>
			<xsl:call-template name="xwkP:CSS"/>
		</style>
	</xsl:template>

	
	<!-- create site level CSS -->
	<xsl:template name="xwkS:CSS"/>
	<!-- create app level CSS -->
	<xsl:template name="xwkA:CSS"/>
	<!-- create page level CSS -->
	<xsl:template name="xwkP:CSS"/>


	<!--
		Called From:  xwk:HEAD<br/>
		By Default: Imports the following jscript <br/>
		/xwk.library.20.jscript/script.aculo.us/prototype.js <br/>
		/xwk.library.20.jscript/script.aculo.us/scriptaculous.js <br/>
		/xwk.library.20.jscript/xwk_generics.js <br/>
		/xwk.library.20.jscript/xwk_Framework_TemplateHelp.js <br/>
		Additional Help:  <a href="~help.aspx#a_js_technologies">- Click Here -</a>
	-->
	<xsl:template name="xwk:JSCRIPT">
		<script language="JavaScript" type="text/javascript" src="/xwk.codebase/library.jscript/script.aculo.us/prototype.js?6.0"/>
		<script language="JavaScript" type="text/javascript" src="/xwk.codebase/library.jscript/script.aculo.us/scriptaculous.js"></script>
		<script language="JavaScript" type="text/javascript" src="/xwk.codebase/library.jscript/script.aculo.us/cookies.js"></script>
		<script language="JavaScript" type="text/javascript" src="/xwk.codebase/library.jscript/xwk_generics.js"></script>
		<script language="JavaScript" type="text/javascript" src="/xwk.codebase/library.jscript/xwk_Framework_TemplateHelp.js"></script>

		<xsl:call-template name="xwkS:JSCRIPT"/>
		<xsl:call-template name="xwkA:JSCRIPT"/>
		<xsl:call-template name="xwkP:JSCRIPT"/>
	</xsl:template>
	
	<!--
	Called From: xwk:JSCRIPT
	Recommend: OVERRIDE and then include your site level JavaScript function
	Recommend: Create template xwkP:JSCRIPT and call from site (page level javascript)
	-->
	<xsl:template name="xwkS:JSCRIPT">
		<xsl:comment>in xwkS:JSCRIPT xwk.xsl</xsl:comment>
	</xsl:template>
	<xsl:template name="xwkA:JSCRIPT">
		<xsl:comment>in xwkA:JSCRIPT xwk.xsl</xsl:comment>
	</xsl:template>
	<xsl:template name="xwkP:JSCRIPT">
		<xsl:comment>in xwkP:JSCRIPT xwk.xsl</xsl:comment>
	</xsl:template>

	<!--
		Called From:  xwk:MAIN<br/>
		Use: Develop your agencies site-level template here <br/>
		Calls: xwkA:MAIN	"application"
	-->
	<xsl:template name="xwkS:MAIN">
		<body>
			<xsl:call-template name="xwkA:MAIN"/>
		</body>
	</xsl:template>

	<!--
		Called From: xwkS:MAIN<br/>
		Use:  Develop your application-level template from here<br/>
		Calls: xwkP:MAIN <br/>
	-->
	<xsl:template name="xwkA:MAIN">
		<xsl:call-template name="xwkP:MAIN"/>
	</xsl:template>

	<!--
		Called From: xwk:APPLICATION_MAIN <br/>
		Use: ..and finally, Develop Your Page!
	-->
	<xsl:template name="xwkP:MAIN">
		<div class="wrapper_menu">
			<xsl:apply-templates select="$xwk:MENU" mode="inc:menus"/>
		</div>
		<div class="wrapper_content">
			<div class="small floatr">
				<a href="#" onclick="Element.toggle('self_documentation_info'); return false;">Turn off self-documentation:  override xwk:PAGE_MAIN</a>
			</div>
			<div id="self_documentation_info" class="msg_box" style="display:none">
				To Hide this self-documentation document you must override
				the template rule xwk:PAGE_MAIN
				To do this, you must first create an xsl template for your own
				use.  This template must inherit (import) from the wap base template
				located here:  <br/>/xwk.documents.xsl/xwk.xsl
				<div class="floatr">
					<a href="#" onclick="Element.hide('self_documentation_info'); return false;">-close me-</a>
				</div>
			</div>
			<div>
				<xsl:apply-templates select="document('')/xsl:stylesheet/xsl:template[@match='root']" mode="xwk:self_document_this_template"/>
				<h3>
					<a href="#" onclick="Element.toggle('xwk_named_templates'); return false;">Named Templates</a>
				</h3>
				<p>
					The following named template are setup with differnt entry points for a site level template, application level template,
					and page level templates.  You will chose to jump in to the FWK where and how it is appropriate to your application
					development.  It is recommended to develop your own application level template which your page level applications will
					import (inherit) from.
				</p>
				<div id="xwk_named_templates">
					<xsl:apply-templates select="document('')/xsl:stylesheet/xsl:template[@name]" mode="xwk:self_document_this_template"/>
				</div>
			</div>
			<xsl:call-template name="xwk:FWK_XML"/>
		</div>
	</xsl:template>
	
	<!--
		Spit out FWK XML - this is your key to debugging...
	-->
	<xsl:template name="xwk:FWK_XML">
		<div id="xwk_xml"  class="clear">
			<h1>FWK XML</h1>
			<xsl:if test="/root/app/tags/node[@name='TRACE']">
				<h3>
					<a href="#" onclick="Element.toggle('xwk_trace'); return false;">TRACE</a>
				</h3>
				<div id="xwk_trace" style="display:none">
					<ul>
						<xsl:apply-templates select="/root/app/tags/node[@name='TRACE']" mode="xwk:identity_transform_html" />
					</ul>
				</div>
			</xsl:if>
			<xsl:if test="/root/app/tags/node[not(@name='TRACE')]">
				<h3>
					<a href="#" onclick="Element.toggle('xwk_tags'); return false;">TAGS</a>
				</h3>
				<div id="xwk_tags" style="display:none">
					<ul>
						<xsl:apply-templates select="/root/app/tags/node[not(@name='TRACE')]" mode="xwk:identity_transform_html" />
					</ul>
				</div>
			</xsl:if>
			<h3>
				<a href="#" onclick="Element.toggle('wap'); return false;">wap</a>
			</h3>
			<div id="wap" style="display:none">
				<xsl:apply-templates select="/root/wap/browser" mode="xwk:identity_transform_html" />
				<xsl:apply-templates select="/root/app/tags/node[not(@name='TRACE')]" mode="xwk:identity_transform_html" />
			</div>
			<h3>
				<a href="#" onclick="Element.toggle('xwk:results'); return false;">Results</a>
			</h3>
			<div id="xwk:results">
				<xsl:apply-templates select="root/app/results/result" mode="xwk:results"/>
			</div>
			<div>
				<a href="#" onclick="Element.toggle('xwk_xml_show'); Element.toggle('xwk_xml'); return false;">-hide wap xml-</a>
			</div>
		</div>
		<div id="xwk_xml_show">
			<a href="#" onclick="Element.toggle('xwk_xml_show'); Element.toggle('xwk_xml'); return false;">-show wap xml-</a>
		</div>
		<h3>
			<a href="#" onclick="Element.toggle('xwk:errors'); return false;">Errors</a>
		</h3>
		<div id="xwk:errors">
			<xsl:apply-templates select="$xwk:Errors" mode="xwk:results"/>
		</div>

	</xsl:template>

	<xsl:template name="xwk:Results">
		<xsl:apply-templates select="/root/app/results" mode="xwk:results" />	
	</xsl:template>
	
	<xsl:template match="results" mode="xwk:results">
		<xsl:apply-templates select="request" mode="xwk:results"/>
	</xsl:template>

	<xsl:template match="request" mode="xwk:results">
		<xsl:apply-templates select="result" mode="xwk:results"/>	
	</xsl:template>
	
		<xsl:template match="result">
			<xsl:param name="visible" select="true()"/>
			<xsl:apply-templates select="." mode="xwk:results">
				<xsl:with-param name="visible" select="$visible"/>
			</xsl:apply-templates>
		</xsl:template>

	<!-- suppress all results who's command type is not "Select" -->
		<xsl:template match="result[preceding-sibling::command[@type!='Select']]" mode="xwk:results"/>
		<xsl:template match="result[preceding-sibling::command[@type!='Select']]" mode="xwk:caption_results"/>

		<xsl:template match="result" mode="xwk:results">
			<xsl:param name="visible" select="true()"/>
			<div id="wrapper_results_{@name}" class="wrapper_xwk_results">
				<xsl:if test="$visible = false()">
					<xsl:attribute name="style">display:none</xsl:attribute>
				</xsl:if>
				<a name="{@name}"></a>

				<xsl:apply-templates select="." mode="xwk:header_results"/>

				<table class="xwk_results" id="results_{@name}">
					<xsl:apply-templates select="." mode="xwk:caption_results"/>
					<xsl:if test="schema">
						<tr>
							<xsl:apply-templates select="schema/node" mode="xwk:results"/>
						</tr>
					</xsl:if>
					<xsl:apply-templates select="data" mode="xwk:results"/>
				</table>
				
				<xsl:apply-templates select="." mode="xwk:results_footer"/>
				
			</div>
	</xsl:template>

	<!-- context: <result /> -->
	<xsl:template match="result" mode="xwk:caption_results">
		<caption>
			<xsl:value-of select="@name"/>
		</caption>
	</xsl:template>
	
	<xsl:template match="result" mode="xwk:header_results"/>
	
	<!-- context: <result /> -->
	<xsl:template match="result" mode="xwk:results_footer">
			<xsl:apply-templates select="data" mode="xwk:paging"/>
	</xsl:template>
	
	<xsl:template match="data" mode="xwk:results">
		<xsl:apply-templates select="row" mode="xwk:results">
			<xsl:sort select="@*[name()=key('xwk:QF', 'sort')]/."/>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="schema/node" mode="xwk:results">
		<xsl:variable name="name" select="ancestor::result[1]/@name"/>
		<th>
			<!-- give first th an id attribute, useful for moving things around client-side -->
			<xsl:if test="position()=1">
				<xsl:attribute name="id">
					<xsl:value-of select="concat('th_',$name)"/>
				</xsl:attribute>
				<!-- add self doc help ico -->
			</xsl:if>
			<xsl:if test="@name=key('xwk:QF','sort')">
				<xsl:attribute name="class">sorted</xsl:attribute>
			</xsl:if>
			<xsl:variable name="parms">
				<xsl:value-of select="concat('submittedrequest=',$name ,'&amp;CurrentPage=',key('xwk:QF','CurrentPage'), '&amp;sort=', @name)"/>
				<xsl:apply-templates select="/root/wap/browser/*[name()='querystring' or name()='formvars']/node" mode="xwk:resultnav_queryvars">
					<xsl:with-param name="type">querystring</xsl:with-param>
				</xsl:apply-templates>
			</xsl:variable>
			<a href="{$xwk:DOC_ACTION}?{$parms}#{$name}">
				<xsl:value-of select="@name"/>
			</a>
		</th>	
	</xsl:template>
	
	<!-- context: data -->
	<xsl:template name="xwk:paging" match="data" mode="xwk:paging">
		<xsl:variable name="name" select="parent::result[1]/@name"/>
		<div id="paging_{@name}" class="xwk_paging" onmouseover="Element.show('nav_help');" onmouseout="Element.hide('nav_help');">
			<form action="{$xwk:DOC_ACTION}#{$name}">
				<input type="hidden" name="submittedrequest" value="{$name}"/>
				<!-- persist current browser / query vars -->
				<xsl:apply-templates select="/root/wap/browser/*[name()='querystring' or name()='formvars']/node" mode="xwk:resultnav_queryvars"/>
				<input type="hidden" name="CurrentPage" value="{@page}"/>
				<input type="submit" name="Direction" value="First Page"/>
				<input type="submit" name="Direction" value="Next Page"/>
				<input type="submit" name="Direction" value="Prev Page"/>
				<div class="xwk_results">
					<span>
						Showing Records: <xsl:value-of select="concat(@recordsfrom, ' to ', @recordsto)"/>
					</span>
				</div>
				<div class="xwk_results">
					<span>
						<xsl:text>Page: </xsl:text>
						<xsl:value-of select="concat(@page, ' of ', @totalpages)"/>
					</span>
					<xsl:call-template name="xwk:paging_pageselect"/>
				</div>
				<div id="nav_help">
					To customize navigation paging, just override &lt;xwk:paging /&gt;
				</div>
			</form>
		</div>
	</xsl:template>


	<!-- context: data -->
	<xsl:template name="xwk:paging_pageselect">
		<xsl:variable name="name" select="parent::result[1]/@name"/>
		<div id="pageselect_{$name}" class="pageselect">
			<ul>
				<xsl:call-template name="xwk:recurse_buildpageselector">
					<xsl:with-param name="num" select="1"/>
				</xsl:call-template>
			</ul>
		</div>
		
	</xsl:template>

	<!-- context: data -->
	<xsl:template name="xwk:recurse_buildpageselector">
		<xsl:param name="num"/>
		<xsl:variable name="name" select="parent::result[1]/@name"/>
		<xsl:variable name="parms">
			<xsl:value-of select="concat('submittedrequest=',$name ,'&amp;CurrentPage=',$num)"/>
			<xsl:apply-templates select="/root/wap/browser/*[name()='querystring' or name()='formvars']/node" mode="xwk:resultnav_queryvars">
				<xsl:with-param name="type">querystring</xsl:with-param>
			</xsl:apply-templates>
		</xsl:variable>
		<li>
			<a href="{$xwk:DOC_ACTION}?{$parms}#{$name}">
				<xsl:value-of select="concat('Page..', $num)"/>
			</a>
		</li>
		<xsl:if test="$num &lt; @totalpages">
			<xsl:call-template name="xwk:recurse_buildpageselector">
				<xsl:with-param name="num" select="$num + 1"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template match="node" mode="xwk:resultnav_queryvars">
		<xsl:param name="type">hidden_form</xsl:param>
		
		<xsl:variable name="n" select="@name"/>
			<xsl:if test="not($n = 'CurrentPage' or $n = 'Direction' or $n = 'submittedrequest')"><!--  or $n = 'RowCount'-->
				<xsl:choose>
					<xsl:when test="hidden_form">
						<input type="hidden" name="{$n}" value="{.}"/>
					</xsl:when>
					<xsl:when test="querystring">
						<xsl:value-of select="concat($n,'=',.)"/>
						<xsl:if test="not(position()=last())">
							<xsl:text>&amp;</xsl:text>
						</xsl:if>
					</xsl:when>
				</xsl:choose>

			</xsl:if>
	</xsl:template>

	<xsl:template match="row" mode="xwk:results">
		<xsl:apply-templates select="." mode="xwk:results_row"/>
	</xsl:template>
	
	<xsl:template match="row" mode="xwk:results_row">
		<xsl:param name="id"/>
		<xsl:param name="title"/>
		<xsl:param name="class"/>
		<tr>
			<xsl:if test="string($id)">
				<xsl:attribute name="id">
					<xsl:value-of select="$id"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="string($title)">
				<xsl:attribute name="title">
					<xsl:value-of select="$title"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="string($class)">
				<xsl:attribute name="class">
					<xsl:value-of select="$class"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates select="@*" mode="xwk:results"/>
		</tr>
	</xsl:template>

	<xsl:template match="row[position() mod 2 = 0]" mode="xwk:results_row">
		<xsl:param name="id"/>
		<xsl:param name="title"/>
		<xsl:param name="class"/>
		<tr>
			<xsl:if test="string($id)">
				<xsl:attribute name="id">
					<xsl:value-of select="$id"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="string($title)">
				<xsl:attribute name="title">
					<xsl:value-of select="$title"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="string($class)">
				<xsl:attribute name="class">
					<xsl:value-of select="$class"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="class">
				<xsl:text>odd</xsl:text>
				<xsl:if test="string(class)">
					<xsl:value-of select="concat(' ', $class)"/>
				</xsl:if>
			</xsl:attribute>
			<xsl:apply-templates select="@*" mode="xwk:results"/>
		</tr>
	</xsl:template>

	<!-- td -->
	<xsl:template match="@*" mode="xwk:results">
		<td>
			<xsl:if test="name()=key('xwk:QF','sort')">
				<xsl:attribute name="class">sorted</xsl:attribute>
			</xsl:if>
			<xsl:value-of select="."/>
		</td>
	</xsl:template>

	<!-- empty td -->
	<xsl:template match="@*[not(string(.))]" mode="xwk:results">
		<td>
			<xsl:if test="name()=key('xwk:QF','sort')">
				<xsl:attribute name="class">sorted</xsl:attribute>
			</xsl:if>
			<xsl:text>&#160;</xsl:text>
		</td>
	</xsl:template>

	<xsl:template match="browser" mode="xwk:identity_transform_html">
		<h4>Form (POST) Vars</h4>
		<ul>
			<xsl:apply-templates select="formvars/node" mode="xwk:identity_transform_html"/>
		</ul>
		<h4>Qeurystring (GET) Vars</h4>
		<ul>
			<xsl:apply-templates select="querystring/node" mode="xwk:identity_transform_html"/>
		</ul>
		<h4>Cookie Vars</h4>
		<ul>
			<xsl:apply-templates select="cookievars/node" mode="xwk:identity_transform_html"/>
		</ul>
		<h4>Session Vars</h4>
		<ul>
			<xsl:apply-templates select="sessionvars/node" mode="xwk:identity_transform_html"/>
		</ul>
	</xsl:template>

	<xsl:template match="node" mode="xwk:identity_transform_html">
		<li>
			<xsl:value-of select="concat(@name, ': ', .)"/>
		</li>
	</xsl:template>

	<xsl:template match="app" mode="xwk:identity_transform_html">
	</xsl:template>

	<xsl:template match="node[@trace]" mode="xwk:identity_transform_html">
		<div>
			<xsl:value-of select="concat('TRACE: ', .)"/>
		</div>
	</xsl:template>

	<xsl:template match="xsl:template" mode="xwk:self_document_this_template">
		<span class="large color_grey">
			<xsl:text>&lt;xsl:template </xsl:text>
		<xsl:choose>
			<xsl:when test="@name">name</xsl:when>
			<xsl:otherwise>match</xsl:otherwise>
		</xsl:choose>
			<xsl:text>="</xsl:text></span>
		<span class="large bold">
			<xsl:value-of select="@name | @match"/>
		</span>
		<span class="large color_grey">"&gt;</span>
		
		<div class="xwk_topic">
			<xsl:value-of disable-output-escaping="yes" select="preceding-sibling::node()[not(self::text()[not(normalize-space())])][1][self::comment()]"/>	
		</div>

	
	</xsl:template>
	
	<!-- lorem ipsum -->
	<xsl:template name="xwk:lorem_ipsum">
		<p>
			Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer ut nisl. Mauris eu nisl. Etiam diam. Suspendisse nibh eros, sodales non, sollicitudin sit amet, ornare vitae, arcu. Ut in nisi. Morbi viverra pulvinar eros. Aliquam ligula turpis, fermentum ac, eleifend et, aliquam at, ligula. Mauris varius gravida nisl. Quisque lacinia. Fusce commodo placerat mauris. Proin dictum dignissim arcu. Maecenas nec eros. In ac libero. Aliquam egestas, mi vel pulvinar condimentum, ante purus pretium eros, eget sagittis ligula sapien sed urna. Suspendisse nec sapien eu urna sollicitudin venenatis. Vestibulum sed metus. Praesent lobortis turpis id lectus. Vivamus id nisi et felis lacinia condimentum. Suspendisse quis sem.
		</p>
		<p>
			Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer ut nisl. Mauris eu nisl. Etiam diam. Suspendisse nibh eros, sodales non, sollicitudin sit amet, ornare vitae, arcu. Ut in nisi. Morbi viverra pulvinar eros. Aliquam ligula turpis, fermentum ac, eleifend et, aliquam at, ligula. Mauris varius gravida nisl. Quisque lacinia. Fusce commodo placerat mauris. Proin dictum dignissim arcu. Maecenas nec eros. In ac libero. Aliquam egestas, mi vel pulvinar condimentum, ante purus pretium eros, eget sagittis ligula sapien sed urna. Suspendisse nec sapien eu urna sollicitudin venenatis. Vestibulum sed metus. Praesent lobortis turpis id lectus. Vivamus id nisi et felis lacinia condimentum. Suspendisse quis sem.
		</p>
		<p>
			Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer ut nisl. Mauris eu nisl. Etiam diam. Suspendisse nibh eros, sodales non, sollicitudin sit amet, ornare vitae, arcu. Ut in nisi. Morbi viverra pulvinar eros. Aliquam ligula turpis, fermentum ac, eleifend et, aliquam at, ligula. Mauris varius gravida nisl. Quisque lacinia. Fusce commodo placerat mauris. Proin dictum dignissim arcu. Maecenas nec eros. In ac libero. Aliquam egestas, mi vel pulvinar condimentum, ante purus pretium eros, eget sagittis ligula sapien sed urna. Suspendisse nec sapien eu urna sollicitudin venenatis. Vestibulum sed metus. Praesent lobortis turpis id lectus. Vivamus id nisi et felis lacinia condimentum. Suspendisse quis sem.
		</p>
	</xsl:template>
	
	<!-- Error matching limited -->
	<xsl:template match="error">
		<xsl:apply-templates select="." mode="xwk:Errors"/>
	</xsl:template>
	
	<xsl:template match="error/node">
		<xsl:apply-templates select="." mode="xwk:Errors"/>
	</xsl:template>

	<xsl:template match="error" mode="xwk:Errors">
		<xsl:if test="node[@name='friendly']">
			<ul class="errors_friendly">
				Errors (friendly):
				<xsl:apply-templates select="node[@name='friendly']" mode="xwk:Errors"/>
			</ul>
		</xsl:if>
		<xsl:if test="node[@name='exception']">
			<ul class="errors_exception">
				Errors (exception):
				<xsl:apply-templates select="node[@name='exception']" mode="xwk:Errors"/>
				<xsl:if test="node[@name='innerexception']">
					<ul class="errors_exception_inner">
						<xsl:apply-templates select="node[@name='innerexception']" mode="xwk:Errors"/>
					</ul>
				</xsl:if>
			</ul>
			
		</xsl:if>
	</xsl:template>
	<xsl:template match="error/node" mode="xwk:Errors">
		<li>
			Exception:
			<xsl:value-of select="."/>
		</li>
	</xsl:template>
	
	
	<!-- add phantom page extension-->
	<xsl:template name="xwk:Phantom_Action">
		<xsl:param name="phantom"/>
		<!-- strip page extension -->
		<xsl:value-of select="concat(substring-before($xwk:DOC_ACTION, $xwk_EXTENSION), '.', $phantom, $xwk_EXTENSION)"/>
	</xsl:template>
</xsl:stylesheet> 
